package com.qeegoo.b2bautozityp.moudle.detail.adapter;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.qeegoo.b2bautozityp.R;

import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.badge.BadgePagerTitleView;

import java.util.ArrayList;

/**
 * Created by HongQian.Wang on 2017/10/19.
 */

public class CommonNavifatorAdapter extends CommonNavigatorAdapter {
    private ArrayList<String> mDataList = new ArrayList<String>();
    private ViewPager view_pager;

    public CommonNavifatorAdapter(ViewPager view_pager) {
        mDataList.add("在售商品");
        mDataList.add("历史报价");
        this.view_pager=view_pager;
    }

    @Override
    public int getCount() {
        return mDataList.size();
    }

    @Override
    public IPagerTitleView getTitleView(Context context, final int index) {
        BadgePagerTitleView badgePagerTitleView = new BadgePagerTitleView(context);

        SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context);
        simplePagerTitleView.setNormalColor(context.getResources().getColor(R.color.text_normal));
        simplePagerTitleView.setSelectedColor(context.getResources().getColor(R.color.blue_button_right));
        simplePagerTitleView.setText(mDataList.get(index));

        simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                view_pager.setCurrentItem(index);
            }
        });
        badgePagerTitleView.setInnerPagerTitleView(simplePagerTitleView);

        return badgePagerTitleView;
    }

    @Override
    public IPagerIndicator getIndicator(Context context) {
        LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context);
        linePagerIndicator.setColors(context.getResources().getColor(R.color.blue_button_right));
        return linePagerIndicator;
    }
}
